package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.FeedSyncHistory;
import org.nterlearning.datamodel.catalog.model.FeedSyncHistoryModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the FeedSyncHistory service. Represents a row in the &quot;CATALOG_FeedSyncHistory&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.FeedSyncHistoryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FeedSyncHistoryImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see FeedSyncHistoryImpl
 * @see org.nterlearning.datamodel.catalog.model.FeedSyncHistory
 * @see org.nterlearning.datamodel.catalog.model.FeedSyncHistoryModel
 * @generated
 */
public class FeedSyncHistoryModelImpl extends BaseModelImpl<FeedSyncHistory>
    implements FeedSyncHistoryModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a feed sync history model instance should use the {@link org.nterlearning.datamodel.catalog.model.FeedSyncHistory} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_FeedSyncHistory";
    public static final Object[][] TABLE_COLUMNS = {
            { "syncId", Types.BIGINT },
            { "feedReferenceId", Types.BIGINT },
            { "syncDate", Types.TIMESTAMP },
            { "success", Types.BOOLEAN },
            { "syncMessage", Types.VARCHAR },
            { "numberOfEntries", Types.INTEGER }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_FeedSyncHistory (syncId LONG not null primary key,feedReferenceId LONG,syncDate DATE null,success BOOLEAN,syncMessage VARCHAR(2000) null,numberOfEntries INTEGER)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_FeedSyncHistory";
    public static final String ORDER_BY_JPQL = " ORDER BY feedSyncHistory.syncId ASC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_FeedSyncHistory.syncId ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.FeedSyncHistory"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.FeedSyncHistory"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.FeedSyncHistory"),
            true);
    public static long FEEDREFERENCEID_COLUMN_BITMASK = 1L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.FeedSyncHistory"));
    private static ClassLoader _classLoader = FeedSyncHistory.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            FeedSyncHistory.class
        };
    private long _syncId;
    private long _feedReferenceId;
    private long _originalFeedReferenceId;
    private boolean _setOriginalFeedReferenceId;
    private Date _syncDate;
    private Boolean _success;
    private String _syncMessage;
    private Integer _numberOfEntries;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private FeedSyncHistory _escapedModelProxy;

    public FeedSyncHistoryModelImpl() {
    }

    public long getPrimaryKey() {
        return _syncId;
    }

    public void setPrimaryKey(long primaryKey) {
        setSyncId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_syncId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return FeedSyncHistory.class;
    }

    public String getModelClassName() {
        return FeedSyncHistory.class.getName();
    }

    public long getSyncId() {
        return _syncId;
    }

    public void setSyncId(long syncId) {
        _columnBitmask = -1L;

        _syncId = syncId;
    }

    public long getFeedReferenceId() {
        return _feedReferenceId;
    }

    public void setFeedReferenceId(long feedReferenceId) {
        _columnBitmask |= FEEDREFERENCEID_COLUMN_BITMASK;

        if (!_setOriginalFeedReferenceId) {
            _setOriginalFeedReferenceId = true;

            _originalFeedReferenceId = _feedReferenceId;
        }

        _feedReferenceId = feedReferenceId;
    }

    public long getOriginalFeedReferenceId() {
        return _originalFeedReferenceId;
    }

    public Date getSyncDate() {
        return _syncDate;
    }

    public void setSyncDate(Date syncDate) {
        _syncDate = syncDate;
    }

    public Boolean getSuccess() {
        return _success;
    }

    public void setSuccess(Boolean success) {
        _success = success;
    }

    public String getSyncMessage() {
        if (_syncMessage == null) {
            return StringPool.BLANK;
        } else {
            return _syncMessage;
        }
    }

    public void setSyncMessage(String syncMessage) {
        _syncMessage = syncMessage;
    }

    public Integer getNumberOfEntries() {
        return _numberOfEntries;
    }

    public void setNumberOfEntries(Integer numberOfEntries) {
        _numberOfEntries = numberOfEntries;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public FeedSyncHistory toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (FeedSyncHistory) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    FeedSyncHistory.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        FeedSyncHistoryImpl feedSyncHistoryImpl = new FeedSyncHistoryImpl();

        feedSyncHistoryImpl.setSyncId(getSyncId());
        feedSyncHistoryImpl.setFeedReferenceId(getFeedReferenceId());
        feedSyncHistoryImpl.setSyncDate(getSyncDate());
        feedSyncHistoryImpl.setSuccess(getSuccess());
        feedSyncHistoryImpl.setSyncMessage(getSyncMessage());
        feedSyncHistoryImpl.setNumberOfEntries(getNumberOfEntries());

        feedSyncHistoryImpl.resetOriginalValues();

        return feedSyncHistoryImpl;
    }

    public int compareTo(FeedSyncHistory feedSyncHistory) {
        int value = 0;

        if (getSyncId() < feedSyncHistory.getSyncId()) {
            value = -1;
        } else if (getSyncId() > feedSyncHistory.getSyncId()) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        FeedSyncHistory feedSyncHistory = null;

        try {
            feedSyncHistory = (FeedSyncHistory) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = feedSyncHistory.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        FeedSyncHistoryModelImpl feedSyncHistoryModelImpl = this;

        feedSyncHistoryModelImpl._originalFeedReferenceId = feedSyncHistoryModelImpl._feedReferenceId;

        feedSyncHistoryModelImpl._setOriginalFeedReferenceId = false;

        feedSyncHistoryModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<FeedSyncHistory> toCacheModel() {
        FeedSyncHistoryCacheModel feedSyncHistoryCacheModel = new FeedSyncHistoryCacheModel();

        feedSyncHistoryCacheModel.syncId = getSyncId();

        feedSyncHistoryCacheModel.feedReferenceId = getFeedReferenceId();

        Date syncDate = getSyncDate();

        if (syncDate != null) {
            feedSyncHistoryCacheModel.syncDate = syncDate.getTime();
        } else {
            feedSyncHistoryCacheModel.syncDate = Long.MIN_VALUE;
        }

        feedSyncHistoryCacheModel.success = getSuccess();

        feedSyncHistoryCacheModel.syncMessage = getSyncMessage();

        String syncMessage = feedSyncHistoryCacheModel.syncMessage;

        if ((syncMessage != null) && (syncMessage.length() == 0)) {
            feedSyncHistoryCacheModel.syncMessage = null;
        }

        feedSyncHistoryCacheModel.numberOfEntries = getNumberOfEntries();

        return feedSyncHistoryCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(13);

        sb.append("{syncId=");
        sb.append(getSyncId());
        sb.append(", feedReferenceId=");
        sb.append(getFeedReferenceId());
        sb.append(", syncDate=");
        sb.append(getSyncDate());
        sb.append(", success=");
        sb.append(getSuccess());
        sb.append(", syncMessage=");
        sb.append(getSyncMessage());
        sb.append(", numberOfEntries=");
        sb.append(getNumberOfEntries());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(22);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.FeedSyncHistory");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>syncId</column-name><column-value><![CDATA[");
        sb.append(getSyncId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>feedReferenceId</column-name><column-value><![CDATA[");
        sb.append(getFeedReferenceId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>syncDate</column-name><column-value><![CDATA[");
        sb.append(getSyncDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>success</column-name><column-value><![CDATA[");
        sb.append(getSuccess());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>syncMessage</column-name><column-value><![CDATA[");
        sb.append(getSyncMessage());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>numberOfEntries</column-name><column-value><![CDATA[");
        sb.append(getNumberOfEntries());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
